1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.IconPaintable;
26 
27 private import gdk.PaintableIF;
28 private import gdk.PaintableT;
29 private import gio.FileIF;
30 private import glib.ConstructionException;
31 private import glib.Str;
32 private import glib.c.functions;
33 private import gobject.ObjectG;
34 private import gtk.SymbolicPaintableIF;
35 private import gtk.SymbolicPaintableT;
36 private import gtk.c.functions;
37 public  import gtk.c.types;
38 
39 
40 /**
41  * Contains information found when looking up an icon in `GtkIconTheme`.
42  * 
43  * `GtkIconPaintable` implements `GdkPaintable`.
44  */
45 public class IconPaintable : ObjectG, PaintableIF, SymbolicPaintableIF
46 {
47 	/** the main Gtk struct */
48 	protected GtkIconPaintable* gtkIconPaintable;
49 
50 	/** Get the main Gtk struct */
51 	public GtkIconPaintable* getIconPaintableStruct(bool transferOwnership = false)
52 	{
53 		if (transferOwnership)
54 			ownedRef = false;
55 		return gtkIconPaintable;
56 	}
57 
58 	/** the main Gtk struct as a void* */
59 	protected override void* getStruct()
60 	{
61 		return cast(void*)gtkIconPaintable;
62 	}
63 
64 	/**
65 	 * Sets our main struct and passes it to the parent class.
66 	 */
67 	public this (GtkIconPaintable* gtkIconPaintable, bool ownedRef = false)
68 	{
69 		this.gtkIconPaintable = gtkIconPaintable;
70 		super(cast(GObject*)gtkIconPaintable, ownedRef);
71 	}
72 
73 	// add the Paintable capabilities
74 	mixin PaintableT!(GtkIconPaintable);
75 
76 	// add the SymbolicPaintable capabilities
77 	mixin SymbolicPaintableT!(GtkIconPaintable);
78 
79 
80 	/** */
81 	public static GType getType()
82 	{
83 		return gtk_icon_paintable_get_type();
84 	}
85 
86 	/**
87 	 * Creates a `GtkIconPaintable` for a file with a given size and scale.
88 	 *
89 	 * The icon can then be rendered by using it as a `GdkPaintable`.
90 	 *
91 	 * Params:
92 	 *     file = a `GFile`
93 	 *     size = desired icon size
94 	 *     scale = the desired scale
95 	 *
96 	 * Returns: a `GtkIconPaintable` containing
97 	 *     for the icon. Unref with g_object_unref()
98 	 *
99 	 * Throws: ConstructionException GTK+ fails to create the object.
100 	 */
101 	public this(FileIF file, int size, int scale)
102 	{
103 		auto __p = gtk_icon_paintable_new_for_file((file is null) ? null : file.getFileStruct(), size, scale);
104 
105 		if(__p is null)
106 		{
107 			throw new ConstructionException("null returned by new_for_file");
108 		}
109 
110 		this(cast(GtkIconPaintable*) __p, true);
111 	}
112 
113 	/**
114 	 * Gets the `GFile` that was used to load the icon.
115 	 *
116 	 * Returns %NULL if the icon was not loaded from a file.
117 	 *
118 	 * Returns: the `GFile` for the icon
119 	 */
120 	public FileIF getFile()
121 	{
122 		auto __p = gtk_icon_paintable_get_file(gtkIconPaintable);
123 
124 		if(__p is null)
125 		{
126 			return null;
127 		}
128 
129 		return ObjectG.getDObject!(FileIF)(cast(GFile*) __p, true);
130 	}
131 
132 	/**
133 	 * Get the icon name being used for this icon.
134 	 *
135 	 * When an icon looked up in the icon theme was not available, the
136 	 * icon theme may use fallback icons - either those specified to
137 	 * gtk_icon_theme_lookup_icon() or the always-available
138 	 * "image-missing". The icon chosen is returned by this function.
139 	 *
140 	 * If the icon was created without an icon theme, this function
141 	 * returns %NULL.
142 	 *
143 	 * Returns: the themed icon-name for the
144 	 *     icon, or %NULL if its not a themed icon.
145 	 */
146 	public string getIconName()
147 	{
148 		return Str.toString(gtk_icon_paintable_get_icon_name(gtkIconPaintable));
149 	}
150 
151 	/**
152 	 * Checks if the icon is symbolic or not.
153 	 *
154 	 * This currently uses only the file name and not the file contents
155 	 * for determining this. This behaviour may change in the future.
156 	 *
157 	 * Note that to render a symbolic `GtkIconPaintable` properly (with
158 	 * recoloring), you have to set its icon name on a `GtkImage`.
159 	 *
160 	 * Returns: %TRUE if the icon is symbolic, %FALSE otherwise
161 	 */
162 	public bool isSymbolic()
163 	{
164 		return gtk_icon_paintable_is_symbolic(gtkIconPaintable) != 0;
165 	}
166 }